package com.ruoyi.web.controller.sxt;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.sxt.domain.SxtGangwei;
import com.ruoyi.sxt.service.ISxtGangweiService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗位信息Controller
 * 
 * @author ruoyi
 * @date 2025-02-25
 */
@RestController
@RequestMapping("/sxt/gangwei")
public class SxtGangweiController extends BaseController
{
    @Autowired
    private ISxtGangweiService sxtGangweiService;

    /**
     * 查询岗位信息列表
     */
    @PreAuthorize("@ss.hasPermi('sxt:gangwei:list')")
    @GetMapping("/list")
    public TableDataInfo list(SxtGangwei sxtGangwei)
    {
        //这是分页代码
        //这是我的web分支
        startPage();
        List<SxtGangwei> list = sxtGangweiService.selectSxtGangweiList(sxtGangwei);
        return getDataTable(list);
    }

    /**
     * 导出岗位信息列表
     */
    @PreAuthorize("@ss.hasPermi('sxt:gangwei:export')")
    @Log(title = "岗位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SxtGangwei sxtGangwei)
    {
        List<SxtGangwei> list = sxtGangweiService.selectSxtGangweiList(sxtGangwei);
        ExcelUtil<SxtGangwei> util = new ExcelUtil<SxtGangwei>(SxtGangwei.class);
        util.exportExcel(response, list, "岗位信息数据");
    }

    /**
     * 获取岗位信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('sxt:gangwei:query')")
    @GetMapping(value = "/{postId}")
    public AjaxResult getInfo(@PathVariable("postId") Long postId)
    {
        return success(sxtGangweiService.selectSxtGangweiByPostId(postId));
    }

    /**
     * 新增岗位信息
     */
    @PreAuthorize("@ss.hasPermi('sxt:gangwei:add')")
    @Log(title = "岗位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SxtGangwei sxtGangwei)
    {
        return toAjax(sxtGangweiService.insertSxtGangwei(sxtGangwei));
    }

    /**
     * 修改岗位信息
     */
    @PreAuthorize("@ss.hasPermi('sxt:gangwei:edit')")
    @Log(title = "岗位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SxtGangwei sxtGangwei)
    {
        return toAjax(sxtGangweiService.updateSxtGangwei(sxtGangwei));
    }

    /**
     * 删除岗位信息
     */
    @PreAuthorize("@ss.hasPermi('sxt:gangwei:remove')")
    @Log(title = "岗位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{postIds}")
    public AjaxResult remove(@PathVariable Long[] postIds)
    {
        return toAjax(sxtGangweiService.deleteSxtGangweiByPostIds(postIds));
    }
}
